﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WanPiJie.WebSite.Avatar
{
	public partial class AvatarPanel : System.Web.UI.UserControl
	{
		/// <summary>
		/// 当前登录用户Id
		/// </summary>
		private int userId;

		/// <summary>
		/// 当前登录用户的Id
		/// </summary>
		public int UserId
		{
			get
			{
				return userId;
			}
			set
			{
				if (value > 0)
				{
					userId = value;
				}
				else
				{
					throw new ArgumentException("UserId为大于零的值");
				}
			}
		}

		/// <summary>
		/// 当前的宝宝Id
		/// </summary>
		private int babyId;

		/// <summary>
		/// 宝宝Id
		/// </summary>
		public int BabyId
		{
			get
			{
				return babyId;
			}
			set
			{
				if (value > 0)
				{
					babyId = value;
				}
				else
				{
					throw new ArgumentException("babyId为大于零的值");
				}
			}
		}

		/// <summary>
		///当前需要上传的头像类型
		/// </summary>
		private AvatarType avatarType;

		/// <summary>
		/// 当前需要上传的头像类型
		/// </summary>
		public AvatarType AvatarType
		{
			get { return avatarType; }
			set { avatarType = value; }
		}

		/// <summary>
		/// 当期图片预览区域的宽度
		/// </summary>
		private int width;

		/// <summary>
		/// 当前图片预览区域的宽度
		/// </summary>
		public int Width
		{
			get { return width; }
			set { width = value; }
		}

		/// <summary>
		/// 当前图片预览区的高度
		/// </summary>
		private int height;

		/// <summary>
		/// 当前图片预览区域的高度
		/// </summary>
		public int Height
		{
			get { return height; }
			set { height = value; }
		}

		/// <summary>
		/// 当前签名串
		/// </summary>
		public string Signature
		{
			get
			{
				return WpjUtility.GetMd5Hash(string.Format("{0}&{1}&{2}&{3}{4}"
					, this.UserId
					, DateTime.Now.ToString("yyyy-MM-dd")
					, this.AvatarType.ToString("G")
					, this.UserId.ToString()
					, this.BabyId.ToString()));
			}
		}
	}
}